Optimizing my Ford-Fulkerson implementation for sparse graphs.
[and.git] / 11526 - H(n) / 11526.2.cpp
blob3787112f44bc66792ebcb42cb34e83944e43865c
1 #include <iostream>
2 #include <cstdio>
3 using namespace std;
5 int n;
6 int main(){
7 int t; scanf("%d", &t);
8 while (t-- && scanf("%d", &n)==1){
9 if (n <= 0){ puts("0"); continue; }
11 long long res = 0;
12 unsigned int i = 1;
13 while (i <= n){
14 int k = n / i;
15 int j = n / k;
16 if (k <= 0 || j <= 0 || i <= 0) for(;;);
17 res += 1LL * (j - i + 1) * k;
18 i = j + 1;
20 printf("%lld\n", res);
22 return 0;